﻿<UserControl x:Class="Tanis.Controls.RouteDetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:loc="clr-namespace:Tanis.Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480" 
    x:Name="RouteDetailsUserControl"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">

    <UserControl.Resources>
        <loc:VisibilityConverter x:Key="ImageConverter" True="Visible" False="Collapsed"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Top" Height="Auto" Margin="5,12,5,0">
            <TextBlock Name="RouteTimeSummary" FontSize="22" VerticalAlignment="Stretch" />
            <ItemsControl Name="DescriptionComposite" Margin="5,0,0,0" VerticalAlignment="Center">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Text}" Foreground="{Binding Color}" FontSize="22" />
                            <Image Source="{Binding ImagePath}" Margin="0,0,0,3" Width="25" Height="25"
                                   Visibility="{Binding ImagePath, Converter={StaticResource ImageConverter}}" />
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel Width="245"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </StackPanel>

        <ListBox Grid.Row="1" Name="_routeDetailCtrl" Margin="5,15,5,12" HorizontalAlignment="Left" 
                 Width="445" MaxHeight="450" ScrollViewer.ManipulationMode="Control" 
                 Background="{Binding ElementName=RouteDetailsUserControl, Path=ThemeDependantListBoxColor}" 
                 BorderBrush="{Binding ElementName=RouteDetailsUserControl, Path=ThemeDependantColorInverted}" 
                 BorderThickness="2"
                 >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120"/>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition Width="100"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="50"></RowDefinition>
                            <RowDefinition Height="50"></RowDefinition>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Path=StartTime, Mode=OneWay}" FontWeight="Bold" />
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=StartDescription, Mode=OneWay}" TextWrapping="Wrap" FontWeight="Bold" />
                        
                        <toolkit:WrapPanel Grid.Column="2" Grid.Row="0" HorizontalAlignment="Right" Margin="0,0,70,0">
                            <TextBlock Text="{Binding Path=Transport, Mode=OneWay}" Foreground="{Binding Path=TransportColor}" />
                            <Image Source="{Binding Path=TransportImage, Mode=OneWay}" Width="25" Height="25" Margin="10,0,0,22" />
                        </toolkit:WrapPanel>
                       
                        <TextBlock Grid.Column="3" Grid.Row="0" Text="" />
                        <TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding Path=EndTime, Mode=OneWay}" />
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=EndDescription, Mode=OneWay}" TextWrapping="Wrap" />
                        <TextBlock Grid.Column="2" Grid.Row="1" Text="" />
                        <TextBlock Grid.Column="3" Grid.Row="1" Text="" />
                        
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
     </Grid>
</UserControl>
